from common.base import Base, By


class UpdatePage(Base):
    def modify(self):
        # 定位编辑按钮点击
        self.click((By.XPATH, '//*[@id="listDiv"]/table[1]/tbody/tr[3]/td[13]/a[2]'))

    def inp_goods(self, content):
        # 清空输入框
        self.find_element((By.XPATH, '//*[@id="general-table"]/tbody/tr[1]/td[2]/input[1]')).clear()
        # 定位商品名称输入框
        self.find_element((By.XPATH, '//*[@id="general-table"]/tbody/tr[1]/td[2]/input[1]')).send_keys(content)

    def classification_goods(self, index):
        # 定位商品分类输入框
        self.select((By.XPATH, '//*[@id="general-table"]/tbody/tr[3]/td[2]/select'), index)

    def price_goods(self, num):
        # 清空输入框
        self.find_element((By.XPATH, '//*[@id="general-table"]/tbody/tr[7]/td[2]/input[1]')).clear()
        # 定位售卖价格输入框
        self.find_element((By.XPATH, '//*[@id="general-table"]/tbody/tr[7]/td[2]/input[1]')).send_keys(num)

    def btn(self):
        # 定位确定输入框
        self.click((By.XPATH, '//*[@id="tabbody-div"]/form/div/input[2]'))

    def get_first_goods(self):
        # 获取商品列表第一个商品名称
        return self.get_element_text((By.XPATH, '//*[@id="listDiv"]/table[1]/tbody/tr[3]/td[3]/span'))


